/**
 * Copyright [2019] [LiBo/Alex of copyright liboware@gmail.com ]
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.hyts.monitor.profile.bean;

import lombok.AllArgsConstructor;
import lombok.Data;

import java.time.Clock;
import java.time.ZoneId;
import java.util.Calendar;
import java.util.Objects;
import java.util.StringTokenizer;
import java.util.TimeZone;

/**
 * @project-name:coffice-toolbox
 * @package-name:com.hyts.monitor.profile.bean
 * @author:LiBo/Alex
 * @create-date:2019-08-20 18:07
 * @copyright:libo-alex4java
 * @email:liboware@gmail.com
 * @description:
 */
@AllArgsConstructor
@Data
public class TimeBean {

    /**
     * 时
     */
    private int hour;

    /**
     * 分
     */
    private int minutes;

    /**
     * 秒
     */
    private int seconds;

    /**
     * date pattern HH:mm:ss
     * @param dateStr
     * @return
     */
    public static TimeBean of(String dateStr){
       String[] strings = dateStr.split(":");
       return new TimeBean(Integer.parseInt(strings[0]),Integer.parseInt(strings[1]),Integer.parseInt(strings[2]));
    }

    /**
     * 是否大于传入的时间对象
     * @return
     */
    public boolean isMoreThan(TimeBean timeBean){
        Objects.requireNonNull(timeBean);
        //比较小时单位
        if(this.getHour() > timeBean.getHour()){
            return true;
        }else if(this.getHour() == timeBean.getHour()){
            if(this.getMinutes() > timeBean.getMinutes()){
               return true;
            }else if(this.getMinutes() == timeBean.getMinutes()){
                if(this.getSeconds() > timeBean.getSeconds()){
                    return true;
                }else if(this.getSeconds() == timeBean.getSeconds()){
                    return false;
                }else{
                    return false;
                }
            }else{
                return false;
            }
        }else {
            return false;
        }
    }

    /**
     * 是否小于传入的时间对象
     * @param timeBean
     * @return
     */
    public boolean isLessThan(TimeBean timeBean){
        return !isMoreThan(timeBean);
    }



}
